
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <!-- Bootstrap -->
    <link rel="stylesheet" type="text/css"  href="${pageContext.request.contextPath}/res/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/res/fonts/font-awesome/css/font-awesome.css">
    <title>Tell a Story</title>
    <!-- Stylesheet
    ================================================== -->
    <link rel="stylesheet" type="text/css"  href="${pageContext.request.contextPath}/res/css/style.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/res/css/responsive.css">
    <script src="${pageContext.request.contextPath}/res/js/jquery-1.11.2.min.js"></script>
    <script src="${pageContext.request.contextPath}/res/js/bootstrap.js"></script>
    <script>
        var onPageNum;
        $(function(){
            onPageNum  =  1;
            $("#FF1").removeClass("active");
            $("#FF2").removeClass("active");
            $("#FF3").removeClass("active");
            $("#FF4").removeClass("active");
            $("#FF5").addClass("active");
            var isSuccess= "${isSuccess}";
            if(isSuccess=="true"){
                $("#alertInfo").show();
                $("#alertInfo").text("删除成功");
                setTimeout(function(){$("#alertInfo").hide();},2000);
            }
            else if(isSuccess=="false"){
                $("#alertWrong").show();
                $("#alertWrong").text("删除失败");
                setTimeout(function(){$("#alertInfo").hide();},2000);
            }
            <% request.getSession().removeAttribute("isSuccess");%>
        });

        function page(goPage) {
            if(goPage=="next"){
                onPageNum = onPageNum+1;
            }
            else if(goPage=="prev"){
                if(onPageNum<=1) return ;
                else onPageNum = onPageNum-1;
            }
            var params = {
                pageNum : onPageNum
            };
            $.ajax({
                type: "POST",
                url: "/drafts/goPage",
                data: params,
                dataType:"html", //ajax返回值设置为text（json格式也可用它返回，可打印出结果，也可设置成json）
                success: function(data){
                    var draftsDTOList = $(data).find("#draftsDTOList");

                    if(draftsDTOList.html()!=null){
                        $("#drafts").empty();
                        $("#drafts").append(draftsDTOList).html();
                    }
                    else{
                        onPageNum=onPageNum-1;
                    }
                },
                error: function(data){
                    alert("服务器错误");
                    return false;
                }
            });
        }// end function page

        function deleteArticle(draftsID) {
            $('#myModal').modal();
            $("#draftsID").val(draftsID);
        }
    </script>
</head>
<body>
<!-- Main Navigation
================================================== -->
<jsp:include   page="../nav.jsp" flush="true"/>
<div id="tf-features">
    <jsp:include   page="sectionHeader.jsp" flush="true"/>


    <div id="feature" class="gray-bg"> <!-- fullwidth gray background -->
        <div class="container"> <!-- container -->
            <div class="row" role="tabpanel"> <!-- row -->
                <jsp:include   page="menuOption.jsp" flush="true"/>
                <div class="col-md-6"> <!-- right content col 6 -->
                    <div class="tab-content features-content"> <!-- tab content wrapper -->
                        <div  class="tab-pane fade in active">
                                <div id="drafts">
                                    <c:forEach var="drafts" items="${draftsDTOList}" varStatus="vs">
                                        <div  id="draftsDTOList" class="post-wrap"> <!-- Post Wrapper -->
                                            <div class="media post"> <!-- post wrap -->

                                                <div class="media-body">
                                                    <p class="small">${drafts.genTime}</p>
                                                    <h5 class="media-heading"><strong>${drafts.draftsName}</strong></h5>
                                                </div>
                                            </div><!-- end post wrap -->

                                            <div class="post-meta"> <!-- Meta details -->
                                                <ul class="list-inline metas pull-left"> <!-- post metas -->
                                                    <li><a href="/myBlog/goWriteBlog?draftsID=${drafts.draftsID}">编辑</a></li> <!-- meta author -->
                                                    <li><a href="" onclick="deleteArticle('${drafts.draftsID}');return false" >删除</a></li> <!-- meta comments -->
                                                </ul>
                                            </div><!-- end Meta details -->
                                        </div><!-- end Post Wrapper -->
                                    </c:forEach>
                                </div>
                                <c:if test="${draftsDTOList!=null}">
                                    <div class="text-left"> <!-- Blogrol Pagination -->
                                        <nav>
                                            <ul class="pagination">
                                                <li>
                                                    <a href="" aria-label="Previous" onclick="page('prev');return false">
                                                        <span aria-hidden="true">Prev</span>
                                                    </a>
                                                </li>

                                                <li>
                                                    <a href="" aria-label="Next" onclick="page('next');return false">
                                                        <span aria-hidden="true" >Next</span>
                                                    </a>
                                                </li>
                                            </ul>
                                        </nav>
                                    </div>
                                </c:if>
                        </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


<!-- Footer
================================================== -->
<jsp:include   page="../foot.jsp" flush="true"/>


<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">操作提示</h4>
            </div>
            <div id="optionInfo" class="modal-body">确定要删除该草稿吗？</div>
            <div id="buttons" class="modal-footer">
                <form action="/drafts/deleteDrafts" method="post">
                    <input id="draftsID" name="draftsID" type="hidden" />
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary">确定</button>
                </form>

            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

</body>
</html>
